if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].IsDifferent') and OBJECTPROPERTY(id, N'IsScalarFunction') = 1)
DROP FUNCTION [dbo].IsDifferent

GO

CREATE FUNCTION dbo.IsDifferent
(
	@field1 sql_variant,
	@field2 sql_variant
)
RETURNS bit
AS
BEGIN
	IF @field1 is null AND @field2 is null RETURN 0
	IF @field1 is null OR @field2 is null RETURN 1
	IF @field1 <> @field2 RETURN 1
	RETURN 0
END
GO

